<template>
  <div>员工抽奖</div>
  <ul>
    <li v-for="(item, index) in userList">{{ item }}</li>
  </ul>
  <button @click="lottery">抽奖</button>
</template>
<script setup>
import { ref } from "vue";
const userList = ref([
  "员工1",
  "员工2",
  "员工3",
  "员工4",
  "员工5",
  "员工6",
  "员工7",
  "员工8",
  "员工9",
  "员工10",
]);
const lottery = () => {
  const index = Math.floor(Math.random() * userList.value.length);
  const lotteryUser = userList.value.splice(index, 1);
  userList.value.sort(() => Math.random() - 0.5);
  alert(lotteryUser + "中奖了");
};
</script>
